From 31ef2b1848b6f6acaf9975067b66f4bc4e75fe08 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Tue, 31 Jul 2007 09:39:14 +0100 Subject: [PATCH] vmx: Simplify event-injection logic. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/vmx/vmx.c | 54 +++---------------------------- xen/include/asm-x86/hvm/vmx/vmx.h | 22 +++---------- 2 files changed, 10 insertions(+), 66 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 9aea14cfd0..d8f1317c38 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2853,47 +2853,6 @@ static void vmx_do_extint(struct cpu_user_regs *regs) } } -static void vmx_reflect_exception(struct vcpu *v) -{ - int error_code, intr_info, vector; - - intr_info = __vmread(VM_EXIT_INTR_INFO); - vector = intr_info & 0xff; - if ( intr_info & INTR_INFO_DELIVER_CODE_MASK ) - error_code = __vmread(VM_EXIT_INTR_ERROR_CODE); - else - error_code = VMX_DELIVER_NO_ERROR_CODE; - -#ifndef NDEBUG - { - unsigned long rip; - - rip = __vmread(GUEST_RIP); - HVM_DBG_LOG(DBG_LEVEL_1, "rip = %lx, error_code = %x", - rip, error_code); - } -#endif /* NDEBUG */ - - /* - * According to Intel Virtualization Technology Specification for - * the IA-32 Intel Architecture (C97063-002 April 2005), section - * 2.8.3, SW_EXCEPTION should be used for #BP and #OV, and - * HW_EXCEPTION used for everything else. The main difference - * appears to be that for SW_EXCEPTION, the EIP/RIP is incremented - * by VM_ENTER_INSTRUCTION_LEN bytes, whereas for HW_EXCEPTION, - * it is not. - */ - if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_SW_EXCEPTION ) - { - int ilen = __get_instruction_length(); /* Safe: software exception */ - vmx_inject_sw_exception(v, vector, ilen); - } - else - { - vmx_inject_hw_exception(v, vector, error_code); - } -} - static void vmx_failed_vmentry(unsigned int exit_reason, struct cpu_user_regs *regs) { @@ -3006,14 +2965,11 @@ asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs) vmx_inject_hw_exception(v, TRAP_page_fault, regs->error_code); break; case TRAP_nmi: - if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI ) - { - HVMTRACE_0D(NMI, v); - vmx_store_cpu_guest_regs(v, regs, NULL); - do_nmi(regs); /* Real NMI, vector 2: normal processing. */ - } - else - vmx_reflect_exception(v); + if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) != INTR_TYPE_NMI ) + goto exit_and_crash; + HVMTRACE_0D(NMI, v); + vmx_store_cpu_guest_regs(v, regs, NULL); + do_nmi(regs); /* Real NMI, vector 2: normal processing. */ break; case TRAP_machine_check: HVMTRACE_0D(MCE, v); diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index a93b4651cd..82938a3728 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -263,8 +263,8 @@ static inline int __vmxon (u64 addr) return rc; } -static inline void __vmx_inject_exception(struct vcpu *v, int trap, int type, - int error_code, int ilen) +static inline void __vmx_inject_exception( + struct vcpu *v, int trap, int type, int error_code) { unsigned long intr_fields; @@ -282,9 +282,6 @@ static inline void __vmx_inject_exception(struct vcpu *v, int trap, int type, intr_fields |= INTR_INFO_DELIVER_CODE_MASK; } - if ( ilen ) - __vmwrite(VM_ENTRY_INSTRUCTION_LEN, ilen); - __vmwrite(VM_ENTRY_INTR_INFO_FIELD, intr_fields); if (trap == TRAP_page_fault) @@ -297,28 +294,19 @@ static inline void vmx_inject_hw_exception( struct vcpu *v, int trap, int error_code) { v->arch.hvm_vmx.vector_injected = 1; - __vmx_inject_exception(v, trap, INTR_TYPE_HW_EXCEPTION, error_code, 0); -} - -static inline void vmx_inject_sw_exception( - struct vcpu *v, int trap, int instruction_len) -{ - v->arch.hvm_vmx.vector_injected = 1; - __vmx_inject_exception(v, trap, INTR_TYPE_SW_EXCEPTION, - VMX_DELIVER_NO_ERROR_CODE, - instruction_len); + __vmx_inject_exception(v, trap, INTR_TYPE_HW_EXCEPTION, error_code); } static inline void vmx_inject_extint(struct vcpu *v, int trap) { __vmx_inject_exception(v, trap, INTR_TYPE_EXT_INTR, - VMX_DELIVER_NO_ERROR_CODE, 0); + VMX_DELIVER_NO_ERROR_CODE); } static inline void vmx_inject_nmi(struct vcpu *v) { __vmx_inject_exception(v, 2, INTR_TYPE_NMI, - VMX_DELIVER_NO_ERROR_CODE, 0); + VMX_DELIVER_NO_ERROR_CODE); } #endif /* __ASM_X86_HVM_VMX_VMX_H__ */ -- 2.30.2